<?php 
/**
 * 
 * Generador de Clave de Cookie
 * @author natanael
 * 
 */
class Key extends Controller{
	
	function __construct(){
		 parent::controller();
		 $this->load->model(array('mkey','usuarios'));
		 $this->load->helper('cookie');
	}
	
   public function index(){
  
   	 $clave = $this->mkey->loadById();
    $this->load->view('main', array('content_page' => 'key','menutop' =>0,'ojt'=>$clave));
    
  }
  
  public function setControl()
  {
  	  $usuario = $this->usuarios->LoadUsuarioById(1);
  	  
  	  if ($usuario->getUsernameUsuario() == $this->input->post('user') && $usuario->getClaveUsuario() == $this->input->post('clave')) 
  	  {
  	  	$key = $this->mkey->loadById();
  	  	set_cookie('company24h', $key->getDescriccion(), 120006);
  	  	 redirect('http://company24h.com/c24h');
  	  }else{
  	  	 redirect('http://company24h.com');
  	  }  	 	
  }
  
  public function control()
  {
  	  $this->load->view('control');
  }
  
  public function save(){
  	
  	$clave = $this->input->post('nombre');
  	
  	$clave = crypt($clave,03);
  	$clave .= crypt($clave,20);
  	$clave .= crypt($clave,24);
  	$clave .= crypt($clave,41);
  	$clave .= crypt($clave,11);
  	$clave .= crypt($clave,26);
  	
  	if ($this->mkey->updateKey($clave) == true) {
  		redirect('key');
  	}
  	
  }
	
	
}


?>